package com.g001.enums;

public enum LevelType {

	AMATEUR(0,100),
	NOVICE(1,500),
	EXPERT(2,2000),
	MASTER(3,5000),
	DIVINITY(4,10000)
	;
	private int id;
	private int minLevelXp;
	
	LevelType(final int id, final int minLevelXp){
		this.id = id;
		this.minLevelXp = minLevelXp;
	}
	
	public int getId(){
		return id;
	}
	
	public static LevelType getLevelById(final int id){
		switch(id){
			case 0 : return AMATEUR;
			case 1 : return NOVICE;
			case 2 : return EXPERT;
			case 3 : return MASTER;
			case 4 : return DIVINITY;
			default : throw new IllegalArgumentException("The following LevelType id '"+id+"' is incorrect.");
		}
	}
	
	public static LevelType getLevel(final int xp){
		if(xp>DIVINITY.minLevelXp) return DIVINITY;
		else 
		if(xp>MASTER.minLevelXp) return MASTER;
		else 
		if(xp>EXPERT.minLevelXp) return EXPERT;
		else 
		if(xp>NOVICE.minLevelXp) return NOVICE;
		else return AMATEUR;
	}

	public int getMinLevelXp() {
		return minLevelXp;
	}
}
